var fs = require('fs');
module.exports = function (path, data, cb) {
    try {
        var base64 = data.replace(/^data:image\/\w+;base64,/, "");//去掉图片base64码前面部分data:image/png;base64
        var dataBuffer = new Buffer(base64, 'base64'); //把base64码转成buffer对象，
        console.log('dataBuffer是否是Buffer对象：' + Buffer.isBuffer(dataBuffer));
        fs.writeFile(path, dataBuffer, function (err) {//用fs写入文件
            if (err) {
                console.log(err);
            } else {
                console.log('写入成功！');
                if (cb) {
                    cb();
                };
            }
        });
    } catch (error) {
        callback(error, null);
    };
};